{extend name="layout" /}

{block name="breadcrumb"}
<h2>{$title}</h2>
<ol class="breadcrumb">
    <li><a href="{:url('index/index')}">首页</a></li>
    <li><a href="{:url('index')}">语种列表</a></li>
    <li><strong>{$title}</strong></li>
</ol>
{/block}

{block name="main"}
<div class="ibox float-e-margins">
    <div class="ibox-title">
        <h5>{$title}</h5>
    </div>
    <div class="ibox-content">
        <form method="post" class="form-horizontal" onsubmit="return toSubmit()">
            <div class="form-group">
                <label class="col-sm-2 control-label">语种名称</label>
                <div class="col-sm-6">
                    <input type="text" name="name" value="{$model ? $model.name : ''}" class="form-control" required />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">语种Icon</label>
                <div class="col-sm-6">
                    <div id="container">
                        <input type="hidden" name="icon" id="container-input" value="{$model ? $model.icon : ''}">
                        <div id="file-container">
                            {if ( $model && $model.icon ) }
                            <p class="upload_old_img upload_img_box">
                                <img src="{:config('file_prefix').$model.icon}" alt="">
                            </p>
                            {/if}
                        </div><br/>
                        <a href="javascript:void(0);" id="select-container" class='btn btn-primary'>选择文件</a>
                        <a href="javascript:void(0);" id="post-container" class='myPostFiles btn btn-primary'>开始上传</a>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">权重</label>
                <div class="col-sm-6">
                    <input type="text" name="sort_num" value="{$model ? $model.sort_num : 0}" class="form-control" />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-6">
                    <select name="status" class="form-control" required>
                        {foreach $status as $key=>$vo }
                        {if ( $model && $model.status == $key ) }
                        <option value="{$key}" selected>{$vo}</option>
                        {else /}
                        <option value="{$key}">{$vo}</option>
                        {/if}
                        {/foreach}
                    </select>
                </div>
            </div>

            {foreach $class as $key=>$vo }
            <div class="form-group">
                <label class="col-sm-2 control-label">{$vo.typeName}价格</label>
                <div class="col-sm-6">
                    <input type="hidden" name="class[{$vo.type}][id]" value="{$vo.id}" class="form-control" required />
                    <input type="text" name="class[{$vo.type}][money]" value="{$vo.money}" class="form-control" required />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">{$vo.typeName}简介</label>
                <div class="col-sm-6">
                    <textarea name="class[{$vo.type}][content]" id="editor_{$vo.type}" style="width:650px;height:200px;">{$vo.content}</textarea>
                </div>
            </div>
            {/foreach}

            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-2">
                    {if ( $model && $model.id > 0) }
                    <input type="hidden" name="id" value="{$model.id}">
                    {/if}
                    <button class="btn btn-primary" type="submit" id="mySubmitBtn">提交</button>
                    <button class="btn btn-white" type="button"><a href="{:url('index')}">取消</a></button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}

{block name="jsFile"}
{load href="/static/js/plugins/plupload/js/plupload.full.min.js" /}
{load href="/static/js/plugins/ueditor/ueditor.config.js" /}
{load href="/static/js/plugins/ueditor/ueditor.all.min.js" /}
{load href="/static/js/plugins/ueditor/lang/zh-cn/zh-cn.js" /}

<script>
    window.PHP = {
        containerIds: ['container'],
        uploadUrl: "{:url('upload/file', ['type' => 1, 'dir' => 'lang_icon'])}",
        maxSize: '100gb',
        fileNum: 1
    };
    UE.getEditor('editor_1',{
        serverUrl: "{:url('u_editor/upload')}"
    });
    UE.getEditor('editor_2',{
        serverUrl: "{:url('u_editor/upload')}"
    });
    UE.getEditor('editor_3',{
        serverUrl: "{:url('u_editor/upload')}"
    });
</script>
{load href="/static/js/plugins/plupload/upload.js" /}
{/block}